<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>部门列表页面</title>
        <style>
            #logout {
                top: 30px;
                text-decoration: none;
            }

            a {
                text-decoration: none;
            }

            table {
                width: 100%;
                border-collapse: collapse;
            }

            table caption {
                font-size: 2em;
                font-weight: bold;
                margin: 1em 0;
            }

            th, td {
                border: 1px solid #999;
                text-align: center;
                padding: 20px 0;
            }

            table thead tr {
                background-color: #008c8c;
                color: #fff;
            }

            table tbody tr:nth-child(odd) {
                background-color: #eee;
            }

            table tbody tr:hover {
                background-color: #ccc;
            }

            table tbody tr td:first-child {
                color: #f40;
            }

            table tfoot tr td {
                text-align: right;
                padding-right: 220px;
            }
        </style>
    </head>
    <body>

        <script type="text/javascript">
            function del(dno) {
                var ok = window.confirm("亲，删了不可恢复哦！");
                if (ok) {
                    document.location.href = "${pageContext.request.contextPath}/dept/delete?deptno=" + dno;
                }
            }
        </script>
        <div align="right">
            <a href="${pageContext.request.contextPath}/user/logout" id="logout">【安全退出】</a>
        </div>
        <div>
            <h3 align="left">欢迎${user.username}</h3>
            当前实时在线人数：${onlinecount}
            <a href="${pageContext.request.contextPath}/employeeList.jsp">员工模块</a>
            <table border="1px"
                   style="margin:10px 20px 15px 20px">
                <caption>部门列表</caption>
                <thead>
                    <tr>
                        <th>序号</th>
                        <th>部门编号</th>
                        <th>部门名称</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                <c:forEach items="${deptList}" var="dept" varStatus="i">
                    <tr>
                        <td>${i.count}</td>
                        <td>${dept.deptno}</td>
                        <td>${dept.dname}</td>
                        <td>
                            <a href="javascript:void(0)" onclick="del(${dept.deptno})">删除</a>
                            <a href="${pageContext.request.contextPath}/dept/detail?f=edit&deptno=${dept.deptno}">修改</a>
                            <a href="${pageContext.request.contextPath}/dept/detail?f=detail&deptno=${dept.deptno}">详情</a>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
                <tfoot>
                <tr>
                    <td colspan="4">
                        <a href="${pageContext.request.contextPath}/add.jsp">新增部门</a>
                    </td>
                </tr>
                </tfoot>
            </table>
        </div>
    </body>
</html>
